<?php

/**
 * @author thihien
 * @copyright 2011
 */

include_once('includes/general.php');
if(!tep_db_checkDb()) die('khong ket noi dc csdl');
$content='';
$chuoi='';
if(isset($_POST['send']) && $_POST['send']!=""){
    if(isset($_POST['name']) && $_POST['name']!=""){
        $hoten=$_POST['name'];
    }else{
        $chuoi.='Chưa nhập tên.</br>';
    }
    
    if(isset($_POST['email']) && $_POST['email']!=""){
        $email=$_POST['email'];
    }else{
        
        $chuoi.='chưa nhập email.</br>';
    }
     
    if(isset($_POST['diachi']) && $_POST['diachi']!=""){
        $diachi=$_POST['diachi'];
    }else{
        
        $chuoi.='chưa nhập địa chỉ.</br>';
    }
     
    if(isset($_POST['sodienthoai']) && $_POST['sodienthoai']!=""){
        $sodienthoai=$_POST['sodienthoai'];
    }else{
        
        $chuoi.='chưa nhập số điện thoại.</br>';
    }
    
      if(isset($_POST['noidung']) && $_POST['noidung']!=""){
        $noidung=$_POST['noidung'];
    }else{
        $chuoi.='Chưa nhập nội dung.</br>';
    }
   
    if($chuoi==""){
        if($_SESSION['nn']=='vn'){
        $sql="INSERT INTO tbl_lien_he(ten_vn,dia_chi_vn,dien_thoai_vn,email_vn,noi_dung_vn)values('$hoten','$diachi','$sodienthoai','$email','$noidung')";
        $kq=tep_db_query($sql);
        if($kq>0){
            
           #$chuoi.="<span style='color:red';> </span></br></br>";
           echo "<script type=\"text/javascript\">alert('Cám ơn bạn đã gửi mail cho chúng tôi!');</script>";
        }
        else{
            echo "<script type=\"text/javascript\">alert('bạn đã gửi mail thất bại! xin vui lòng gửi lại.');</script>";
        }
        }
        if($_SESSION['nn']=='en'){
            $sql="INSERT INTO tbl_lien_he(ten_en,dia_chi_en,dien_thoai_en,email_en,noi_dung_en)values('$hoten','$diachi','$sodienthoai','$email','$noidung')";
        $kq=tep_db_query($sql);
        if($kq>0){
            
           #$chuoi.="<span style='color:red';> </span></br></br>";
           echo "<script type=\"text/javascript\">alert('Thank you for sending mail to us!');</script>";
        }
        else{
            echo "<script type=\"text/javascript\">alert('you have failed to send mail! please post again.');</script>";
        }
        }
    }
}

if($_SESSION['nn']=='vn'){
$content.='
    <div id="center">
        <div id="lien_he_ys">
            <div id="thongtin_congty">
                <div class="tieude_dm" id="tieude_lienhe"><h3>Liên Hệ </h3></div>
                <div class="noidung_ct"><p >CÔNG TY TNHH THUONG MẠI & DỊCH VỤ THUẬN VĨNH ÐẠT</p>
                    <p class="p1">Ðịa Chỉ: 63a Lê Sao, P.Phú Thạnh, Q.Tân Phú, TPHCM<br/>
                        Tel:(84-8) 39491295 - (84-8) 39491546<br/>
                        Fax:(84-8) 39492500
                        Email:tvd@thuanvinhdat.com<br/>
                        Website:quedt@thuanvinhdat.com
                    </p>
                </div>    
            </div>
            <form  id="fr_lienhe" name="fr_lienhe" method="POST" action="">
                <div id="noidunglienhe">
                    
                    <div class="noidung_lien_he"><h2>Thông Tin Mail</h2></div>
                    <div class="noidung_lien_he">
                        <label >Tên:<span style="color: red;">(*)</span></label>
                        <input type="text" id="name" name="name" size="30"/>
                    </div >
                    <div class="noidung_lien_he">
                        <label >Địa Chỉ:<span style="color: red;">(*)</span></label>
                        <input type="text" id="diachi" name="diachi" size="30"/>
                    </div >
                    <div class="noidung_lien_he">
                        <label >Số Điện Thoại:<span style="color: red;">(*)</span></label>
                        <input type="text" id="sodienthoai" name="sodienthoai" size="30"/>
                    </div >
                    <div class="noidung_lien_he">
                        <label>Email:<span style="color: red;">(*)</span></label>
                        <input type="text" id="email" name="email" size="30"/>
                    </div>
                    <div class="noidung_lien_he">
                        <label>Nội Dung:<span style="color: red;">(*)</span></label>
                        <textarea id="noidung" cols="40" rows="10" name="noidung"></textarea> 
                    </div>
                    <div class="noidung_lien_he_1">
                        <input type="submit" id="send" value="Gửi" name="send"/>
                    </div>
                </div>
            </form>
    </div>
</div>
';
}
if($_SESSION['nn']=='en'){
    $content.='
    <div id="center">
        <div id="lien_he_ys">
            <div id="thongtin_congty">
                <div class="tieude_dm" id="tieude_lienhe"><h3>contact</h3></div>
                <div class="noidung_ct"><p>LIMITED LIABILITY COMPANY & COMMERCIAL SERVICES THUAN VINH DAT</p>
                        <p class="p1"> Address: 63A Le Sao, Phu Thanh Ward, Tan Phu District<br/>
                            Tel:(84-8) 39491295 - (84-8) 39491546<br/>
                            Fax:(84-8) 39492500
                            Email:tvd@thuanvinhdat.com<br/>
                            Website:quedt@thuanvinhdat.com
                        </p>
                </div>    
            </div>
            <form  id="fr_lienhe" name="fr_lienhe" method="POST" action="">
                <div id="noidunglienhe">
                    
                    <div class="noidung_lien_he"><h2> Mail Information </h2></div>
                    <div class="noidung_lien_he">
                        <label >Name:<span style="color: red;">(*)</span></label>
                        <input type="text" id="name" name="name" size="30"/>
                    </div >
                    <div class="noidung_lien_he">
                        <label >Address:<span style="color: red;">(*)</span></label>
                        <input type="text" id="diachi" name="diachi" size="30"/>
                    </div >
                    <div class="noidung_lien_he">
                        <label >Phone:<span style="color: red;">(*)</span></label>
                        <input type="text" id="sodienthoai" name="sodienthoai" size="30"/>
                    </div >
                    <div class="noidung_lien_he">
                        <label>Email:<span style="color: red;">(*)</span></label>
                        <input type="text" id="email" name="email" size="30"/>
                    </div>
                    <div class="noidung_lien_he">
                        <label>Content:<span style="color: red;">(*)</span></label>
                        <textarea id="noidung" cols="40" rows="10" name="noidung"></textarea> 
                    </div>
                    <div class="noidung_lien_he_1">
                        <input type="submit" id="send" value="Send" name="send"/>
                    </div>
                </div>
            </form>
    </div>
</div>
';
}
echo $content;

?>
